package com.guiguli.BigIntegerDemo;

import java.math.BigInteger;

public class BigIntegerDemo2 {
    public static void main(String[] args) {
        //1.创建两个BigInteger对象
        BigInteger bd1 = BigInteger.valueOf(10);
        BigInteger bd2 = BigInteger.valueOf(2);

        //2.加法
        BigInteger bd3 = bd1.add(bd2);
        System.out.println(bd3);

        //4.比较是否相同
        boolean result = bd1.equals(bd2);
        System.out.println(result);

        //5.次幂
        BigInteger bd4 = bd1.pow(2);
        System.out.println(bd4);

        //6.max
        BigInteger bd5 = bd1.max(bd2);
        System.out.println(bd5);

        //7.转为int类型整数，超出范围数据有误
        BigInteger bd6 = BigInteger.valueOf(200);
        var i=bd6.intValue();
        System.out.println(i);
        //还可以使用longValue和doubleValue，short，byte等
        var v = bd6.doubleValue();
        System.out.println(v);
    }

}
